<div ng-controller="invoiceListCtrl">
    <div class="table-header mt5 clearfix ng-scope">
        <span class="fl lh30 f14">发票管理</span>
    </div>
    <div>
        <my-nav data-nav-items="filterDataType" onchanged="changeType" data-title="发票类型:"></my-nav>
        <my-nav data-nav-items="filterDataStatus" onchanged="changeStatus" data-title="发票状态:"></my-nav>
    </div>
    <div class="section-table mt20">
        <div class="table-header lh30 pb5 clearfix">
            <span class="fl f14">发票列表</span>

            <div class="fr btn-group">
                <span class="fl">开票时间：</span>
                <input type="text" class="fl input-text w120 ml3 input-date" ng-model="query.invoice_begin_date"
                       ng-enter="query.execute()" ui-date format="yyyy-MM-dd">
                <span class="fl ml3">-</span>
                <input type="text" class="fl input-text w120 ml3 input-date" ng-model="query.invoice_end_date"
                       ng-enter="query.execute()" ui-date format="yyyy-MM-dd">
                <input type="text" class="fl input-text w200 ml3" placeholder="发票台头/发票号码/合同编号"
                       ng-model="query.searchKey"
                       ng-enter="query.execute()">
                <button class="btn" ng-click="query.execute()">查询</button>
                <!--<button class="btn btn-yellow" ng-click="editInvoice(0)">新建发票</button>-->
                <!--<button class="btn btn-yellow" ng-click="editInvoice(1)">新建主发票</button>-->
                <button class="btn btn-yellow"
                        ui-dialog="新增发票"
                        ui-dialog-data="{}"
                        ui-dialog-show="invoiceService.onInvoiceShow($dialog,$dialogScope, 1)"
                        ui-dialog-ok="invoiceService.editInvoiceSave($data,$dialog,$dialogScope,query.execute,page_index)"
                        ui-dialog-cache="false"
                        ui-dialog-url="/invoice/dialog/invoice_add.html"
                        >新增发票
                </button>
                <button class="btn btn-yellow"
                        ui-dialog="新增主发票"
                        ui-dialog-data="{}"
                        ui-dialog-show="invoiceService.onInvoiceShow($dialog,$dialogScope, 2)"
                        ui-dialog-ok="invoiceService.editInvoiceSave($data,$dialog,$dialogScope,query.execute,page_index)"
                        ui-dialog-cache="false"
                        ui-dialog-url="/invoice/dialog/invoice_add.html"
                        >新增主发票
                </button>
            </div>
        </div>
        <div class="table-wrap mh500 mt10">
            <table class="table">
                <!-- 表头-->
                <thead>
                <tr>
                    <th style="width: 40px;text-align: center;">序号</th>
                    <th style="width: 200px;">开票单位</th>
                    <th style="width: 150px;">合同信息</th>
                    <th style="width: 200px;">发票信息</th>
                    <th style="width: 100px;">发票状态</th>
                    <th style="width: 150px;">金额信息</th>
                    <th style="width: 100px;">附加信息</th>
                    <th>操作</th>
                </tr>
                </thead>
                <!-- 表格内容-->
                <tbody>
                <tr ng-repeat="record in invoices" class="table-tr">
                    <td style="text-align: center"><p ng-bind="$index + 1 + startPageIndex"></p></td>
                    <td>
                        <p ng-bind="record.invoiceCompanyName"></p>
                    </td>
                    <td>
                        <p ng-bind="record.contractCode"></p>

                        <p ng-if="record.contractCompanyName" class="c9">合同所属公司：<span
                                ng-bind="record.contractCompanyName"></span></p>
                    </td>
                    <td>
                        <p>发票台头：<span ng-bind="record.customer_name"></span></p>

                        <p>发票号码：<span ng-bind="record.invoice_no"></span></p>

                        <p class="c9">开票日期：<span ng-bind="record.invoice_date | strdate:'yyyy-MM-dd'"></span></p>
                    </td>
                    <td>
                        <p ng-if="record.is_main_invoice==0">普通发票</p>

                        <p ng-if="record.is_main_invoice==1">主发票</p>

                        <p ng-if="record.invoice_status!=1">未/部分关联</p>

                        <p ng-if="record.invoice_status==1">已全部关联</p>
                    </td>
                    <td>
                        <p>发票金额：<span ng-bind="record.invoice_amount | number:2"></span></p>

                        <div ng-if="record.is_main_invoice==0">
                            <p class="c9">已开票未回款：{{record.invoice_amount - record.payment_amount | number:2}}</p>

                            <p class="c9">关联应收款：{{record.receivables_amount | number:2}}</p>
                        </div>
                        <div ng-if="record.is_main_invoice==1">
                            <p>子发票金额：{{record.totalChildInvoiceAmount | number:2}}</p>
                        </div>
                    </td>
                    <td>
                        <p>是否遗失：
                            <span ng-if="record.is_lose==1">是</span>

                            <span ng-if="record.is_lose!=1">否</span>
                        </p>

                        <p>是否红冲：
                            <span ng-if="record.is_red_invoice==1">是</span>

                            <span ng-if="record.is_red_invoice!=1">否</span>
                        </p>
                    </td>
                    <td>
                        <p ng-if="record.is_red_invoice!=1 && !record.red_by_invoice_id">
                            <!--<a href="javascript:;" ng-click="editInvoice(2,record.invoice_id)">复制</a>-->
                            <a href="javascript:;"
                               ui-dialog="复制发票"
                                    ui-dialog-data="{}"
                                    ui-dialog-show="invoiceService.onInvoiceShow($dialog,$dialogScope, 3,record.invoice_id)"
                                    ui-dialog-ok="invoiceService.editInvoiceSave($data,$dialog,$dialogScope,query.execute,page_index)"
                                    ui-dialog-cache="false"
                                    ui-dialog-url="/invoice/dialog/invoice_add.html"
                                    >复制
                            </a>
                        </p>

                        <p ng-if="!(record.receivables_amount>0) && record.is_red_invoice!=1 && !record.red_by_invoice_id">
                            <!--<a href="javascript:;" ng-click="editInvoice(3,record.invoice_id)">编辑</a>-->
                            <a href="javascript:;"
                               ui-dialog="编辑发票"
                                    ui-dialog-data="{}"
                                    ui-dialog-show="invoiceService.onInvoiceShow($dialog,$dialogScope, 4,record.invoice_id)"
                                    ui-dialog-ok="invoiceService.editInvoiceSave($data,$dialog,$dialogScope,query.execute,page_index)"
                                    ui-dialog-cache="false"
                                    ui-dialog-url="/invoice/dialog/invoice_add.html"
                                    >编辑
                            </a>
                        </p>

                        <p ng-if="record.receivables_amount>0 || record.is_red_invoice==1 || record.red_by_invoice_id">
                            <!--<a href="javascript:;" ng-click="editInvoice(4,record.invoice_id)">查看</a>-->
                            <a href="javascript:;"
                               ui-dialog="查看发票"
                                    ui-dialog-data="{}"
                                    ui-dialog-show="invoiceService.onInvoiceShow($dialog,$dialogScope, 5,record.invoice_id)"
                                    ui-dialog-ok="query.execute(page_index)"
                                    ui-dialog-cache="false"
                                    ui-dialog-url="/invoice/dialog/invoice_add.html"
                                    >查看
                            </a>
                        </p>


                        <p ng-if="!(record.receivables_amount>0) && record.is_red_invoice!=1 && !record.red_by_invoice_id"><a href="javascript:;" ng-click="removeInvoice(record.invoice_id)">删除</a></p>

                        <p ng-if="record.is_lose!=1"><a href="javascript:;"
                                                        ng-click="markLoss(record.invoice_id)">标记遗失</a></p>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="no-data" ng-if="invoices.length == 0"><span>暂无数据</span></div>
        </div>
        <div id="pagination" class="pagination"></div>
    </div>

</div>